package com.example.demo.service.bis.impl;

import com.example.demo.bean.bis.Sign;
import com.example.demo.bean.bis.SignStatistics;
import com.example.demo.repository.SignStatisticsMapper;
import com.example.demo.service.bis.SignStatisticsService;
import com.example.demo.service.exception.ErrorCode;
import com.example.demo.service.exception.ServiceException;
import com.example.demo.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;

import java.text.ParseException;
import java.util.Date;
import java.util.List;

/**
 * @author zzz
 * @Title: SignStatisticsServiceImpl
 * @ProjectName test
 * @Description: TODO()
 * @date 2018/7/17
 */
@Service
@Transactional
public class SignStatisticsServiceImpl implements SignStatisticsService {

    @Autowired private SignStatisticsMapper signStatisticsMapper;

    @Override
    public void updateByUid(Sign sign) throws ParseException {
        if(StringUtils.isEmpty(sign)){
            throw  new ServiceException(ErrorCode.NULL_ERROR);
        }
        Date nowDate =   DateUtils.dateParse(sign.getSignIn(),null);
        Date endDate =   DateUtils.dateParse(sign.getSignBack(),null);
        SignStatistics ss = new SignStatistics();
        //计算小时
        ss.setWorkHours(DateUtils.getDatePoor(nowDate,endDate));
    }
}
